package com.lix.controller.workflow;

import com.lix.config.ProcessConfig;
import com.lix.base.BaseResult;
import com.lix.service.workflow.IProcessConfigService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api(tags = "流程配置控制层")
@RequestMapping("/flow/processConfig")
@RestController
public class ProcessConfigController {
    @Autowired
    private IProcessConfigService processConfigService;

    @ApiOperation("根据流程Key查询流程配置")
    @GetMapping("/{processKey}")
    public BaseResult view(@PathVariable String processKey) {
        return BaseResult.ok(processConfigService.getByProcessKey(processKey));
    }

    @ApiOperation("新增或更新流程配置")
    @PutMapping
    public BaseResult saveOrUpdate(@RequestBody ProcessConfig processConfig) {
        boolean b = processConfigService.saveOrUpdate(processConfig);
        if (b) {
            return BaseResult.ok();
        } else {
            return BaseResult.error("操作失败");
        }
    }
}
